package com.xmotor.controller;

import com.xmotor.cache.CacheFind;
import com.xmotor.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("test_cache")
public class TestCacheStarterController {

    @Autowired
    private UserService userService;

    @CacheFind(key = "user_key_findById",timeout = 30)
    @RequestMapping("/test1")
    public Object test1(@RequestParam(value = "id",defaultValue = "1") Integer id){
        return userService.findById(id);
    }

    @CacheFind
    @RequestMapping("/test2")
    public Object test2(@RequestParam(value = "id",defaultValue = "1") Integer id){
        return userService.findById(id);
    }
}
